package com.lifesting.front;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.faces.component.UIComponent;

import com.lifesting.City;
import com.lifesting.Country;

public final class FacesUtil {
	public static List<Column> getColumn(Table table)
	{
		List<UIComponent> children = table.getChildren();
		List<Column> list = new ArrayList<Column>(children.size());
		for (Iterator<UIComponent> ite = children.iterator(); ite.hasNext();)
		{
			UIComponent c = ite.next();
			if (c instanceof Column) list.add((Column) c);
		}
		return list;
	}
	/**
	 * 通过短名返回hibernate里面class的QualifiedName
	 * @param shortBeanName
	 * @return
	 */
	public static String getQualifiedName(String shortBeanName){
		if (shortBeanName.equals("City")){
			return City.class.getName();
		}
		else if (shortBeanName.endsWith("Country")){
			return Country.class.getName();
		}
		else{
			System.out.println("ERROR: Miss "+shortBeanName);
		}
		return shortBeanName;
	}
}
